package com.rabbiter.oes.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.rabbiter.oes.entity.FillQuestion;
import com.rabbiter.oes.entity.JudgeQuestion;
import org.apache.ibatis.annotations.*;

import java.util.List;

//填空题
@Mapper
public interface FillQuestionMapper extends BaseMapper<FillQuestion> {

    /**
     * 某科目判断题个数
     * @param subjectId
     * @return
     */
    default Long selectCountBysubjectId(String subjectId) {
        return selectCount(Wrappers.lambdaQuery(FillQuestion.class).eq(FillQuestion::getSubjectId, subjectId));
    }

    public List<FillQuestion> findByIdAndType(Integer paperId);

    @Select("select questionId from fill_question order by rand() desc limit #{pageNo}")
    List<Integer> findBySubject(@Param("pageNo") Integer pageNo);

    public IPage<FillQuestion> findAll(Page<FillQuestion> page);

}
